﻿package mortal.game.view.forging.view
{
    import com.gengine.core.frame.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import flash.text.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.palyer.*;
    import mortal.mvc.interfaces.*;

    public class AutoTransferWin extends Window
    {
        private var _bg:ScaleBitmap;
        private var _titleBg:GImageBitmap;
        private var _equip:PlayerEquipItem;
        private var _tipInfo:GTextFiled;
        private var _confirmBtn:GLoadingButton;
        private var _leftTime:SecTimerView;
        private var sectimer:SecTimer;
        public var timeOutFunc:Function;
        private static var _instance:AutoTransferWin;

        public function AutoTransferWin(param1:ILayer = null)
        {
            super(param1);
            this.layer = LayerManager.topLayer;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            _isAddClolseButton = false;
            super.createDisposedChildrenImpl();
            this.mouseEnabled = true;
            this._bg = UIFactory.bg(0, 0, 309, 247, this, ImagesConst.AutoTransferBg);
            this._equip = UICompomentPool.getUICompoment(PlayerEquipItem);
            this._equip.setItemStyle(ItemStyleConst.Big, "", 3, 3);
            this._equip.x = 122;
            this._equip.y = 2;
            this.addChild(this._equip);
            this._titleBg = UIFactory.gImageBitmap(ImagesConst.mountTitleBg, 15, 86, this, this.onBgLoadCompl);
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41067), 121 - 4 + 13, 95, 120, 25, this, GlobalStyle.textFormatHuang2.setSize(14)));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41068), 24, 136, 46, 25, this, GlobalStyle.textFormatHuang.setSize(14)));
            this._tipInfo = UIFactory.gTextField(Language.getString(41069), 63, 136, 228, 25, this, GlobalStyle.textFormatHuang.setSize(14));
            this._tipInfo.multiline = true;
            this._tipInfo.wordWrap = true;
            this._tipInfo.autoSize = TextFieldAutoSize.LEFT;
            this._confirmBtn = UIFactory.gLoadingButton(ResFileConst.AutoTransferConfirmBtn, 101, 196 - 2, 114, 33, this);
            this._confirmBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._leftTime = UIFactory.secTimeView(Language.getString(41070), 59 - 25, 12 - 7, 26 + 20, 22, this._confirmBtn, GlobalStyle.textFormatHuang.setSize(13));
            this._leftTime.setLeftTime(5);
            this._leftTime.timeOutHandler = this.timeOutHandler;
            this.configEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);
            return;
        }// end function

        private function onBgLoadCompl() : void
        {
            this._titleBg.width = 284;
            return;
        }// end function

        private function timeOutHandler() : void
        {
            if (this.timeOutFunc != null)
            {
                this.timeOutFunc.call();
            }
            this.hide();
            return;
        }// end function

        public function setEquip(param1:ItemData) : void
        {
            this._equip.itemData = param1;
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            if (this.timeOutFunc != null)
            {
                this.timeOutFunc.call();
            }
            this.hide();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._bg.dispose();
            this._bg = null;
            this._equip.dispose();
            this._equip = null;
            this._tipInfo.dispose();
            this._tipInfo = null;
            this._confirmBtn.dispose();
            this._confirmBtn = null;
            this._leftTime.dispose();
            this._leftTime = null;
            this._titleBg.dispose();
            this._titleBg = null;
            this.timeOutFunc = null;
            return;
        }// end function

        public static function get instance() : AutoTransferWin
        {
            if (_instance == null)
            {
                _instance = new AutoTransferWin;
            }
            return _instance;
        }// end function

    }
}
